<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0,user-scalable=yes,maximum-scale=1.0">
<title>JSON在线解析工具</title>
<meta name="keywords" content="JSON,在线JSON,JSON 校验,格式化,xml转json 工具,在线工具">
<link rel="stylesheet" type="text/css" href="parse_new.css" />
<style>
.button {
  font-family: Arial;
  color: #101010;
  font-size: 14px;
  background: #fefefe;
  padding: 6px 25px 6px 25px;
  border: solid #a5b0b7 1px;
  text-decoration: none;
}

.button:hover {
  color: #ffffff;
  background: #278bcd;
  text-decoration: none;
}
</style>
</head>
<body>
<div id="container" style="height: 100%;">
    <div class="no-padding-h relative">
        <div class="json-empty">
            <div id="header" class="a">
                <h1 style="margin: 0 45px 0 0; padding: 0; display: block; line-height: 1.1;">
                    <a class="button" href="javascript:formatJson();">格式化</a>
                    <a class="button" href="javascript:compressZipJson();">压缩</a>
                    <a class="button" href="javascript:escapeJson();">转义</a>
                    <a class="button" href="javascript:restoreJson();">去除转义</a>
                    <a class="button" href="javascript:unicode2ch();">Unicode转中文</a>
                    <a class="button" href="javascript:ch2unicode();">中文转Unicode</a>
                </h1></b>
                <div class="c">
                <div class="n b"><span class="l">选项</span><span class="m">▼</span>
                <div class="j g h">
                <div class="e d on" id="yM">左右模式</div>
                <div class="e d" id="xL">上下模式</div>
                <div class="f"></div>
                <div class="e on" id="gV">解析JSON</div>
                <div class="e on" id="jY">执行JSON</div>
                <div class="f"></div>
                <div class="e" id="zN">压缩</div>
                <div class="e on" id="cR">着色</div>
                <div class="e" id="bQ">显示JS类型</div>
                <div class="e" id="aP">显示数组索引</div>
                </div>
                </div>
                </div>
            </div>

            <div id="split" class="N I" style="height: 151px; top: 39px;">
                <textarea class="J x P" id="eT" spellcheck="false" style="height: 139.667px; width: 624.667px;"></textarea>
                <div class="M ui-draggable" style="left: 656px;"></div>
                <div class="K F color" id="fU">
                <div class="y Q">
                <div class="C A" id="hW" style="width: 496px;">准备就绪</div>
                <div class="C B" id="kZ">&nbsp;</div>
                </div>
                <div class="z L" style="height: 113.667px;">
                <div class="E" id="dS">
                <div class="C A" style="width: 496px;float:left">
                <div class="w">
                <div class="P" id="iX"></div>
                </div>
                </div>
                <div class="C B" style="width: 495px;">
                <div class="w D">
                <div class="P" id="lA"></div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="./parse_new_json.js"></script>
<script src="./lz-string-1.4.4.js" type="text/javascript" charset="utf-8"></script>
<script src="./inone.js" type="text/javascript" charset="utf-8"></script>
<script>
    function isMobile() {
        let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
        return flag;
    }

    if (isMobile()) {

    }

    function formatJson() {
        localStorage.setItem('lastJsonData_a', $("#eT").val());
        var jsonVal = jsl.format.formatJson($("#eT").val());
        $("#eT").val(jsonVal)
    }

    function restoreJson() {
        var t = $("#eT").val();
        t = t.replace(/\\\\/g, "\\").replace(/\\\"/g, '"')
        $("#eT").val(t)
    }

    function escapeJson() {
        var t = $("#eT").val();
        t = t.replace(/\\/g, "\\\\").replace(/\"/g, '\\"');
        $("#eT").val(t)
    }

    function isChinese(e) {
        return /[\u4e00-\u9fa5]/.test(e)
    }

    function unicode2ch() {
        var e = $("#eT").val();
        if (e) {
            for (var t = "", n = 0; n < e.length; n++) {
                var i = e.charAt(n);
                t += isChinese(i) ? "\\u" + i.charCodeAt(0).toString(16) : i
            }
            $("#eT").val(t)
        }
    }

    function ch2unicode() {
        var e = $("#eT").val();
        if (e) {
            for (var t = 1, n = "", i = 0; i < e.length; i += t) {
                t = 1;
                var o = e.charAt(i);
                if ("\\" == o)
                    if ("u" == e.charAt(i + 1)) {
                        var r = e.substr(i + 2, 4);
                        n += String.fromCharCode(parseInt(r, 16).toString(10)),
                        t = 6
                    } else
                        n += o;
                else
                    n += o
            }
            $("#eT").val(n)
        }
    }

    function compressZipJson() {
        var t = $("#eT").val();
        t = t.split("\n").join(" ");
        for (var n = [], i = !1, o = 0, r = t.length; r > o; o++) {
            var a = t.charAt(o);
            i && a === i ? "\\" !== t.charAt(o - 1) && (i = !1) : i || '"' !== a && "'" !== a ? i || " " !== a && "	" !== a || (a = "") : i = a,
            n.push(a)
        }
        t = n.join("")
        $("#eT").val(t)
    }

    //初始化上一次json数据
    var lastJson = localStorage.getItem('lastJsonData_a');
    if (lastJson) {
        if (typeof lastJson == 'object') {
            $("#eT").val(JSON.stringify(lastJson));
        } else {
            $("#eT").val(lastJson.toString());
        }
    }
</script>
</body>
</html>
